package org.example.springboot.controller;


import org.example.springboot.common.FileStorageService;
import org.example.springboot.common.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping
public class WebController {

    @PostMapping("/upload")
    public Result upload(@RequestParam("file") MultipartFile file) {
        String fileName = FileStorageService.storeFile(file);
        String fileUrl = "http://localhost:9090/files/" + fileName;


        return Result.success(fileUrl);
    }
}
